//
//  Simple_RSSAppDelegate.m
//  Simple RSS
//
//  Copyright 2008 WillowTree Consulting Group, Inc. All rights reserved.
//

#import "Simple_RSSAppDelegate.h"
#import "Simple_RSSViewController.h"
#import "FeedsViewController.h"
#import "AboutViewController.h"
#import "SettingsViewController.h"
#import "Beacon.h"

#define	APP_CODE		@"74b07d73307d02359101f76ae7099804"

@implementation Simple_RSSAppDelegate

@synthesize window;
@synthesize viewController;


- (void)applicationDidFinishLaunching:(UIApplication *)application {    
	FeedsViewController *fvController = [[FeedsViewController alloc] initWithTitle:@"News" withNavigationTitle:@"Charlottesville Tomorrow" withPropertyFile:@"feeds.plist"];
	FeedsViewController *calController = [[FeedsViewController alloc] initWithTitle:@"Calendar" withNavigationTitle:@"Calendar" withPropertyFile:@"calendar.plist"];
	AboutViewController *avController = [[AboutViewController alloc] init];
	SettingsViewController *svController = [[SettingsViewController alloc] init];
	UINavigationController *fvNavController = [[UINavigationController alloc] initWithRootViewController:fvController];
	UINavigationController *calNavController = [[UINavigationController alloc] initWithRootViewController:calController];
	UINavigationController *avNavController = [[UINavigationController alloc] initWithRootViewController:avController];
	UINavigationController *svNavController = [[UINavigationController alloc] initWithRootViewController:svController];
	UITabBarController *tbController = [[UITabBarController alloc] init];
	
	fvNavController.navigationBar.tintColor = [UIColor colorWithRed:0.14 green:0.18 blue:0.25 alpha:1.00];
	calNavController.navigationBar.tintColor = [UIColor colorWithRed:0.14 green:0.18 blue:0.25 alpha:1.00];
	avNavController.navigationBar.tintColor = [UIColor colorWithRed:0.14 green:0.18 blue:0.25 alpha:1.00];
	svNavController.navigationBar.tintColor = [UIColor colorWithRed:0.14 green:0.18 blue:0.25 alpha:1.00];

	[[calController tabBarItem] setImage:[UIImage imageNamed:@"calendar.png"]];
	[[fvController tabBarItem] setImage:[UIImage imageNamed:@"rss.png"]];
	
	tbController.viewControllers = [NSArray arrayWithObjects:fvNavController, calNavController, avNavController, svNavController, nil];
	
	// Configure and show the window
	[window addSubview:tbController.view];
	[window makeKeyAndVisible];
	
	[Beacon initAndStartBeaconWithApplicationCode:APP_CODE useCoreLocation:YES useOnlyWiFi:NO];
}

- (void)applicationWillTerminate:(UIApplication *)application {
	[[Beacon shared] endBeacon];
}


- (void)dealloc {
    [viewController release];
    [window release];
    [super dealloc];
}


@end
